#ifndef KRAW3DMODEL_H
#define KRAW3DMODEL_H

#include "kernel/ntypes.h"
#include "util/nstring.h"
#include "util/narray.h"

//-----------------------------------------------------------------------------

class nFile;

class Kraw3DModel
{
public:

    enum EVertexFlag
    {
        None = 0,
        Coord = (1<<0),
        Normal = (1<<1),
        TexCoord0 = (1<<2),
        TexCoord1 = (1<<3),
        TexCoord2 = (1<<4),
        TexCoord3 = (1<<5),
        Diffuse = (1<<6),
        Specular = (1<<7),
        Tangent = (1<<8),
        Binormal = (1<<9),
        Weights = (1<<10),
        JIndices = (1<<11),

        NumVertexFlags = 12,
    };

    static Kraw3DModel* Create( const char* );
    static void Cleanup();

    Kraw3DModel();
    ~Kraw3DModel();
 
    void Clear();
    bool IsValid();

    virtual bool Load( nFile* ) = 0;

    bool GetStreamData( EVertexFlag flag, float** data );

    static EVertexFlag StringToVertexFlag( const char* );

    enum EFormat
    {
        InvalidFormat = 0,
        Float2,
        Float3,
        DWord,
    };

    struct Stream
    {
        EVertexFlag type;
        int size;
        int offset;
    };

    struct Batch
    {
        int firstVertex;
        int nVertices;
        int firstIndex;
        int nIndices;
        int firstEdge;
        int nEdges;
    };
    
    bool bIsValid;

    nArray<Stream> streams;
    nArray<Batch> batches;
    uint vertexFlags;
    uint nComponents;
    uint nStreams;
    uint nBatches;
    uint nVertices;
    uint nIndices;
    uint nEdges;
    uint nTriangles;

    float* pVertices;
    uint* pIndices;
    uint* pAttributes;
};

//-----------------------------------------------------------------------------

#endif /*KRAWMODEL_H*/
